// _GraphPropertyDialog.cpp : implementation file
//

#include "stdafx.h"
#include "FlexGraph.h"
#include "_GraphPropertyDialog.h"
#include "afxdialogex.h"


// _GraphPropertyDialog dialog

IMPLEMENT_DYNAMIC(_GraphPropertyDialog, CDialogEx)

_GraphPropertyDialog::_GraphPropertyDialog(CWnd* pParent /*=NULL*/)
    : CDialogEx(_GraphPropertyDialog::IDD, pParent)
{
}

_GraphPropertyDialog::~_GraphPropertyDialog()
{
}

void _GraphPropertyDialog::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
    DDX_Control(pDX, IDC_TAB_PROPERTIES, m_TabProperties);
}


BEGIN_MESSAGE_MAP(_GraphPropertyDialog, CDialogEx)
    ON_NOTIFY(TCN_SELCHANGE, IDC_TAB_PROPERTIES, &_GraphPropertyDialog::OnSelchangeTabProperties)
END_MESSAGE_MAP()


// _GraphPropertyDialog message handlers


BOOL _GraphPropertyDialog::OnInitDialog()
{
    CDialogEx::OnInitDialog();
    // Tabs initialisieren
    TCITEM TabItemMarker;
    TabItemMarker.mask    = TCIF_TEXT | TCIF_PARAM;
    TabItemMarker.lParam  = (LPARAM)&m_TabProperties;
    TabItemMarker.pszText = _T("Marker");
    m_TabProperties.InsertItem(0, &TabItemMarker);
    TCITEM TabItemAppearance;
    TabItemAppearance.mask    = TCIF_TEXT | TCIF_PARAM;
    TabItemAppearance.lParam  = (LPARAM)&m_TabProperties;
    TabItemAppearance.pszText = _T("Graphs");
    m_TabProperties.InsertItem(0, &TabItemAppearance);
    TCITEM TabItemMinMax;
    TabItemMinMax.mask    = TCIF_TEXT | TCIF_PARAM;
    TabItemMinMax.lParam  = (LPARAM)&m_TabProperties;
    TabItemMinMax.pszText = _T("Appearance");
    m_TabProperties.InsertItem(0, &TabItemMinMax);
    // Dialoge erstellen
    CRect RectTabControl;
    m_TabProperties.GetItemRect(0, &RectTabControl);
    m_PropertiesMinMax.Create(IDD_FLEX_GRAPH_PROPERTIES_MIN_MAX, this);
    m_PropertiesMinMax.SetWindowPos(NULL, RectTabControl.left, RectTabControl.bottom + 1, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
    m_PropertiesMinMax.ShowWindow(SW_SHOW);
    m_PropertiesAppearance.Create(IDD_FLEX_GRAPH_PROPERTIES_APPEARANCE, this);
    m_PropertiesAppearance.SetWindowPos(NULL, RectTabControl.left, RectTabControl.bottom + 1, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
    m_PropertiesMarker.Create(IDD_FLEX_GRAPH_PROPERTIES_MARKERS, this);
    m_PropertiesMarker.SetWindowPos(NULL, RectTabControl.left, RectTabControl.bottom + 1, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
    m_TabProperties.SetCurSel(0);
    return TRUE;  // return TRUE unless you set the focus to a control
}


void _GraphPropertyDialog::OnSelchangeTabProperties(NMHDR* pNMHDR, LRESULT* pResult)
{
    int Tab = m_TabProperties.GetCurSel();
    m_PropertiesMinMax.ShowWindow(SW_HIDE);
    m_PropertiesAppearance.ShowWindow(SW_HIDE);
    m_PropertiesMarker.ShowWindow(SW_HIDE);

    switch(Tab)
    {
        case 0:
            m_PropertiesMinMax.ShowWindow(SW_SHOW);
            break;

        case 1:
            m_PropertiesAppearance.ShowWindow(SW_SHOW);
            break;

        case 2:
            m_PropertiesMarker.ShowWindow(SW_SHOW);
            break;

        default:
            break;
    }

    *pResult = 0;
}
